package com.ask.controller.user;

import com.ask.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.ask.constant.RedisConstant.SHOP_STATUS_KEY;

@RestController("userShopController")
@RequestMapping("/user/shop")
public class ShopController {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/status")
    public Result<Integer> getStatus() {
        String statusStr = stringRedisTemplate.opsForValue().get(SHOP_STATUS_KEY);
        Integer status = null;
        if (statusStr != null) {
            status = Integer.parseInt(statusStr);
        }
        return Result.success(status);
    }
}
